import torch
from torch_geometric.data import Data

edge_index = torch.tensor([
    [0,1],[1,2],[1,2],[2,1],[2,0],[1,1]
],dtype = torch.long)
x = torch.tensor([[-1],[0],[1]],dtype=torch.float)
# To use t().contiguous() to rebuild the edge_index value.
data = Data(x=x,edge_index=edge_index.t().contiguous())
print(data)
# Use validate  to confirm the data validation.
print(data.validate(raise_on_error=True))
for key,item in data:
    print("key and item",key,item)
# There has no edge_attr defination
print('edge_attr' in data)
# The x num_node_features is 1 ,but can be embedding to multiply dims.
print(data.num_nodes,data.num_edges,data.num_node_features)
# There has some point xi to xi edge in the graph.
print(data.has_self_loops())
# Some edges have directions.
print(data.is_directed())
# There has some single node without edges.
print(data.has_isolated_nodes())
